package com.hancher.gamelife2.iciba;

import com.hancher.common.androidutil.AsyncUtils;
import com.hancher.common.net.NetUtil;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import io.reactivex.rxjava3.core.Observable;
import retrofit2.http.GET;
import retrofit2.http.Query;

/**
 * 作者: Hancher
 * 日期: 2020/9/6 10:21
 * 描述: 用户操作接口
 */
public class IcibaApi {

    public static String HOST_ICIBA = "http://sentence.iciba.com/";
    public static HancherService service = new NetUtil<>(HancherService.class).setBaseUrl(HOST_ICIBA).build();

    /**
     * 新版每日一句
     * {
     * 	"errno": 0,
     * 	"errmsg": "success",
     * 	"sid": 3742,
     * 	"title": "2020-04-24",
     * 	"content": "The mankind’s courage and resolution will be witnessed and remembered by stars.",
     * 	"note": "人类的勇气和坚毅必将被镌刻在星空之下。",
     * 	"translation": "新版每日一句",
     * 	"picture": "https:\/\/v-sq.ks3-cn-beijing.ksyun.com\/image\/213b880e693178c1a9bb01c5e60ad208.jpg",  长方形
     * 	"picture2": "https:\/\/v-sq.ks3-cn-beijing.ksyun.com\/image\/31918a2a573cb047957ce94efd74edae.jpg", 原图
     * 	"picture3": "https:\/\/v-sq.ks3-cn-beijing.ksyun.com\/image\/6f5b2174bda612bb1cf949e020f88bb3.jpg", 正方形
     * 	"caption": "词霸每日一句",
     * 	"tts": "https:\/\/v-sq.ks3-cn-beijing.ksyun.com\/audio\/cc51b82981fe3dccebb5cac20c8a9efa.mp3",
     * 	"tts_size": "",
     * 	"s_pv": 3549,
     * 	"sp_pv": 0,
     * 	"love": 4257,
     * 	"s_content": "",
     * 	"s_link": "",
     * 	"period": 0,
     * 	"loveFlag": 0,
     * 	"tags": "",
     * 	"keep": 0,
     * 	"comment_count": 1454,
     * 	"last_title": "2020-04-23",
     * 	"next_title": "2020-04-25",
     * 	"week_info": [{
     * 		"week": "Mon",
     * 		"date": "2020-04-20",
     * 		"flag": "show"
     *        }, {
     * 		"week": "Tue",
     * 		"date": "2020-04-21",
     * 		"flag": "show"
     *    }, {
     * 		"week": "Wen",
     * 		"date": "2020-04-22",
     * 		"flag": "show"
     *    }, {
     * 		"week": "Thu",
     * 		"date": "2020-04-23",
     * 		"flag": "show"
     *    }, {
     * 		"week": "Fri",
     * 		"date": "2020-04-24",
     * 		"flag": "cur"
     *    }, {
     * 		"week": "Sat",
     * 		"date": "2020-04-25",
     * 		"flag": "show"
     *    }, {
     * 		"week": "Sun",
     * 		"date": "2020-04-26",
     * 		"flag": "show"
     *    }]
     * }
     * @return
     */
    public static Observable<DailySentence> dailySentence() {
        SimpleDateFormat simpleFormatter = new SimpleDateFormat("yyyy-MM-dd");
        String time = simpleFormatter.format(new Date());
        return service.dailySentence("dailysentence", "getdetail", time)
                .compose(AsyncUtils.getThreadTransformer());
    }

    public static class DailySentence {

        private int errno;
        private String errmsg;
        private int sid;
        private String title;
        private String content;
        private String note;
        private String translation;
        private String picture;
        private String picture2;
        private String picture3;
        private String caption;
        private String tts;
        private String tts_size;
        private int s_pv;
        private int sp_pv;
        private int love;
        private String s_content;
        private String s_link;
        private int period;
        private int loveFlag;
        private String tags;
        private int keep;
        private int comment_count;
        private String last_title;
        private String next_title;
        private List<Week_info> week_info;

        public int getErrno() {
            return errno;
        }

        public DailySentence setErrno(int errno) {
            this.errno = errno;
            return this;
        }

        public String getErrmsg() {
            return errmsg;
        }

        public DailySentence setErrmsg(String errmsg) {
            this.errmsg = errmsg;
            return this;
        }

        public int getSid() {
            return sid;
        }

        public DailySentence setSid(int sid) {
            this.sid = sid;
            return this;
        }

        public String getTitle() {
            return title;
        }

        public DailySentence setTitle(String title) {
            this.title = title;
            return this;
        }

        public String getContent() {
            return content;
        }

        public DailySentence setContent(String content) {
            this.content = content;
            return this;
        }

        public String getNote() {
            return note;
        }

        public DailySentence setNote(String note) {
            this.note = note;
            return this;
        }

        public String getTranslation() {
            return translation;
        }

        public DailySentence setTranslation(String translation) {
            this.translation = translation;
            return this;
        }

        public String getPicture() {
            return picture;
        }

        public DailySentence setPicture(String picture) {
            this.picture = picture;
            return this;
        }

        public String getPicture2() {
            return picture2;
        }

        public DailySentence setPicture2(String picture2) {
            this.picture2 = picture2;
            return this;
        }

        public String getPicture3() {
            return picture3;
        }

        public DailySentence setPicture3(String picture3) {
            this.picture3 = picture3;
            return this;
        }

        public String getCaption() {
            return caption;
        }

        public DailySentence setCaption(String caption) {
            this.caption = caption;
            return this;
        }

        public String getTts() {
            return tts;
        }

        public DailySentence setTts(String tts) {
            this.tts = tts;
            return this;
        }

        public String getTts_size() {
            return tts_size;
        }

        public DailySentence setTts_size(String tts_size) {
            this.tts_size = tts_size;
            return this;
        }

        public int getS_pv() {
            return s_pv;
        }

        public DailySentence setS_pv(int s_pv) {
            this.s_pv = s_pv;
            return this;
        }

        public int getSp_pv() {
            return sp_pv;
        }

        public DailySentence setSp_pv(int sp_pv) {
            this.sp_pv = sp_pv;
            return this;
        }

        public int getLove() {
            return love;
        }

        public DailySentence setLove(int love) {
            this.love = love;
            return this;
        }

        public String getS_content() {
            return s_content;
        }

        public DailySentence setS_content(String s_content) {
            this.s_content = s_content;
            return this;
        }

        public String getS_link() {
            return s_link;
        }

        public DailySentence setS_link(String s_link) {
            this.s_link = s_link;
            return this;
        }

        public int getPeriod() {
            return period;
        }

        public DailySentence setPeriod(int period) {
            this.period = period;
            return this;
        }

        public int getLoveFlag() {
            return loveFlag;
        }

        public DailySentence setLoveFlag(int loveFlag) {
            this.loveFlag = loveFlag;
            return this;
        }

        public String getTags() {
            return tags;
        }

        public DailySentence setTags(String tags) {
            this.tags = tags;
            return this;
        }

        public int getKeep() {
            return keep;
        }

        public DailySentence setKeep(int keep) {
            this.keep = keep;
            return this;
        }

        public int getComment_count() {
            return comment_count;
        }

        public DailySentence setComment_count(int comment_count) {
            this.comment_count = comment_count;
            return this;
        }

        public String getLast_title() {
            return last_title;
        }

        public DailySentence setLast_title(String last_title) {
            this.last_title = last_title;
            return this;
        }

        public String getNext_title() {
            return next_title;
        }

        public DailySentence setNext_title(String next_title) {
            this.next_title = next_title;
            return this;
        }

        public List<Week_info> getWeek_info() {
            return week_info;
        }

        public DailySentence setWeek_info(List<Week_info> week_info) {
            this.week_info = week_info;
            return this;
        }

        public static class Week_info {

            private String week;
            private String date;
            private String flag;

            public String getWeek() {
                return week;
            }

            public Week_info setWeek(String week) {
                this.week = week;
                return this;
            }

            public String getDate() {
                return date;
            }

            public Week_info setDate(String date) {
                this.date = date;
                return this;
            }

            public String getFlag() {
                return flag;
            }

            public Week_info setFlag(String flag) {
                this.flag = flag;
                return this;
            }
        }
    }

    interface HancherService {
        @GET("/index.php")
        Observable<DailySentence> dailySentence(@Query("c") String command, @Query("m") String module, @Query("title") String time);
    }

}
